package com.demo; /**
 * @author wzm
 * @create 2023-06-30 11:28
 */

import com.utils.CodeUtils;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/code.jpg")
public class CodeServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //生成验证码
        String s = CodeUtils.outputVerifyImage(150, 50, response.getOutputStream(), 4);
        //一般验证码如果需要再服务器检验就需要存储
        request.getSession().setAttribute("sessioncode",s);
    }
}
